unit uSAF0003_02;

interface

uses
   Windows,
   Messages,
   SysUtils,
   Variants,
   Classes,
   Graphics,
   Controls,
   Forms,
   Dialogs,
   ComCtrls,
   ToolWin,
   Menus,
   ActnList,
   ImgList,
   ExtCtrls,
   DB,
   ADODB,
   Grids,
   DBGrids,
   DBCtrls,
   StdCtrls,
   Buttons,

   //--< Thread >--//
   uSAF0003_03;

type
   TfrmPrincipal = class(TForm)
      actPrincipal: TActionList;
      actFechar: TAction;
      ilPrincipal: TImageList;
      pnlTopo: TPanel;
      pnlCentro: TPanel;
      imgLogo: TImage;
      pnlInferior: TPanel;
      statPrincipal: TStatusBar;
      tlbPrincipal: TToolBar;
      btnConsultar: TToolButton;
      btnS4: TToolButton;
      btnFechar: TToolButton;
      btnS3: TToolButton;
      lblTIPO: TLabel;
      mmoLog: TMemo;
      btn1: TButton;

      procedure FormShow(Sender: TObject);
      procedure actFecharExecute(Sender: TObject);

      procedure FormKeyPress(Sender: TObject; var Key: Char);
      procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
      procedure btn1Click(Sender: TObject);

   private

      { Private declarations }

   public

      { Public declarations }

   end;

var
   frmPrincipal: TfrmPrincipal;
   _threadSAF0003_03: SAF0003_03;

implementation

{$R *.dfm}

uses
   uLibGlobal,
   uSAF0003_01;

procedure TfrmPrincipal.actFecharExecute(Sender: TObject);
begin
   Self.Close;
end;

procedure TfrmPrincipal.btn1Click(Sender: TObject);
begin
   try
      Application.ProcessMessages;

      _threadSAF0003_03 := SAF0003_03.Create(True);
      _threadSAF0003_03.Priority := tpHighest;
      _threadSAF0003_03.Resume;

      mmoLog.Lines.Add('Ativou a thread.');
   except
      on E: Exception do
      begin
         mmoLog.Lines.Add('Erro na thread.');

         Application.MessageBox(PChar(
            E.Message + #13 + E.ClassName
            ), PChar(Application.Title), MB_OK + MB_ICONINFORMATION);
      end;
   end;
end;

procedure TfrmPrincipal.FormKeyDown(Sender: TObject; var Key: Word;
   Shift: TShiftState);
begin
   fNotCtrlDelete(Key, Shift);
end;

procedure TfrmPrincipal.FormKeyPress(Sender: TObject; var Key: Char);
begin
   fTabToEnter(Key, Self);
end;

procedure TfrmPrincipal.FormShow(Sender: TObject);
begin
   ShortDateFormat := 'dd/mm/yyyy';
   ShortTimeFormat := 'hh:nn:ss';

   if not fValidaWOS(ParamStr(1)) then
      Application.Terminate;

   fMontarTelaPrincipal(Self, 400, 790);
   fCarregarLogo(imgLogo, DMDados._sistema);
   Self.Caption := DMDados._sistemaNome + ' - ' + DMDados._sistemaDescricao;

   lblTIPO.Caption := '';
end;

end.

